package com.loe.httptest

import com.loe.mvp.ext_java.boolean
import com.loe.mvp.ext_java.double
import com.loe.mvp.ext_java.long

class HttpParam
{
    var key: String = ""
    var value: String = ""

    /** String, Number, Boolean */
    var type: String = "String"

    constructor()
    {
    }

    constructor(key: String, value: Any)
    {
        this.key = key
        this.value = value.toString()
        when (value)
        {
            is Number ->
            {
                this.type = "Number"
            }
            is Boolean ->
            {
                this.type = "Boolean"
            }
            else ->
            {
                this.type = "String"
            }
        }
    }

    val realValue: Any
        get()
        {
            return when(type)
            {
                "Number" -> if(value.contains(".")) value.double else value.long
                "Boolean" -> value.boolean
                else -> value
            }
        }
}